namespace MathService
{
    public class ArrayIndexer<T>
    {
        private T[] f_Array;
        private int f_Index;

        public int Length { get { return f_Array.Length; } }

        public int Index { get { return f_Index; } set { f_Index = value; } }

        public T Value { get { return f_Array[f_Index]; } set { f_Array[f_Index] = value; } }

        public T this[int Index] { get { return f_Array[Index]; } set { f_Array[Index] = value; } }

        public T[] Array { get { return f_Array; } set { f_Array = value ?? new T[0]; } }

        public ArrayIndexer() { f_Array = new T[0]; }

        public ArrayIndexer(T[] Array, int Index = 0)
        {
            this.Array = Array;
            f_Index = Index;
        }

        public static implicit operator T[](ArrayIndexer<T> Indexer) { return Indexer.f_Array; }
    }
}